/*Joseph A. Coll
Racial Polarization and Voter Confidence Methods
2/7/2025*/

/*
*Original files
*2016
use "2016 ANES Cleaned.dta", clear

*2020
use "2020 ANES Cleaned.dta", clear
*/

*Append 2016 and 2020 data
use "2016 ANES Cleaned.dta", clear

append using "2020 ANES Cleaned.dta", force

tab year
drop _merge
statastates, abbreviation(state_abbrev)

*Xtset to create change variables
gen panel_year = .
replace panel_year =1 if year == 2016
replace panel_year =2 if year == 2020

*bro V200001 V160001_orig
fre V160001_orig
drop if V160001_orig == -1 | V160001_orig ==.
tab year

xtset V160001_orig panel_year

*Replace 2016 equal to 2016 confidence for those in 2020 
bro year vote_conf_2016 
replace vote_conf_2016 = l1.vote_conf_2016 if year ==2020

*Create change variable
drop if vote_conf == .
bro V160001_orig year vote_conf
gen vote_conf_change = vote_conf - l1.vote_conf
tab vote_conf_change 
label var vote_conf_change "Change in Voter Confidence"
tab vote_conf_change 

*Change voter confidence 3pt
recode vote_conf_change (-4/-1=0 "Decreased") (0=1 "No Change") (1/4=2 "Increased"), gen(vote_conf_change3)
label var vote_conf_change3 "Change in Voter Confidence"
tab vote_conf_change3 

*Change voter confidence 5pt
recode vote_conf_change (-4/-2=0 "Decreased a lot") (-1=1 "Decreased some") (0=2 "No Change") (1=3 "Increased some") (2/4=4 "Increased a lot"), gen(vote_conf_change5)
label var vote_conf_change5 "Change in Voter Confidence"
tab vote_conf_change5 

*Change 0-1
fre vote_conf_change
gen vote_conf_change01 = (vote_conf_change+4)/8
label var vote_conf_change01 "Change in Voter Confidence"
tab vote_conf_change01 

/*
*Change RAP
gen rap_wa_change = rap_wa - l1.rap_wa
label var rap_wa_change "RAP Change: White-Asian"
recode rap_wa_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(rap_wa_change3)
label var rap_wa_change3 "RAP Change: White-Asian"

gen rap_wb_change = rap_wb - l1.rap_wb
label var rap_wb_change "RAP Change: White-Black"
recode rap_wb_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(rap_wb_change3)
label var rap_wb_change3 "RAP Change: White-Black"

gen rap_wl_change = rap_wl - l1.rap_wl
label var rap_wl_change "RAP Change: White-Latino"
recode rap_wl_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(rap_wl_change3)
label var rap_wl_change3 "RAP Change: White-Latino"

gen rap_wii_change = rap_wii - l1.rap_wii
label var rap_wii_change "RAP Change: White-Illegal Immig."
recode rap_wii_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(rap_wii_change3)
label var rap_wii_change3 "RAP Change: White-Illegal Immig."

gen pap_change = pap - l1.pap
label var pap_change "PAP Change"
recode pap_change (-200/-1=-0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(pap_change3)
label var pap_change "PAP Change"

gen plap_change = plap - l1.plap
label var plap_change "PAP Change"
recode plap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(plap_change3)
label var plap_change3 "plap Change"

gen iap_change = iap - l1.iap
label var iap_change "PAP Change"
recode iap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(iap_change3)
label var iap_change3 "IAP Change"

local vars rap_wa_change rap_wb_change rap_wl_change rap_wii_change pap_change plap_change iap_change
foreach x of local vars {
recode `x' (-200/-51=0 "Highly Decreased RAP") (-50/-1=1 "Decreased RAP")(0=2 "No Change") (1/50=3 "Increased RAP") (51/200=4 "Highly Increased RAP"), gen(`x'5)
}

*Change within race group RAP
gen aap_change = ft_asian - l1.ft_asian
label var aap_change "Asian Affective Polarization"
recode aap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(aap_change3)
label var aap_change3 "Asian Affective Polarization Change"

gen bap_change = ft_black - l1.ft_black
label var bap_change "Black Affective Polarization"
recode bap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(bap_change3)
label var bap_change3 "Black Affective Polarization Change"

gen lap_change = ft_lat - l1.ft_lat
label var lap_change "Black Affective Polarization"
recode lap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(lap_change3)
label var lap_change3 "Black Affective Polarization Change"

gen iiap_change = ft_ii - l1.ft_ii
label var iiap_change "Black Affective Polarization"
recode iiap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(iiap_change3)
label var iiap_change3 "Black Affective Polarization Change"

gen wap_change = ft_white - l1.ft_white
label var wap_change "Black Affective Polarization"
recode wap_change (-200/-1=0 "Decreased") (0=1 "No Change") (1/200=2 "Increased"), gen(wap_change3)
label var wap_change3 "Black Affective Polarization Change"
*/

*Rescale IVs 0-1
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap  
foreach x of local vars {
replace `x' = `x'/100  
}

*Rename weights
clonevar panel_weight=V200011b 

clonevar post_weight_2016=V160102

clonevar post_weight_2020=V200010b

tab vote_conf if year ==2016 & e(sample)==1
tab vote_conf if year ==2020 & e(sample)==1

ologit vote_conf_change3 c.rap_wb ///
age educ income_mean married ///
voted conservativism rep_w_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
[pw=panel_weight], robust cluster(V160001_orig)

local vars ft_asian ft_black ft_white ft_lat ft_ii 
foreach x of local vars {
ci mean `x'  
}


sum vote_conf_change5 rap_wb rap_wl rap_wii pap plap iap age educ income_mean married ///
voted conservativism rep_w_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
if e(sample)==1

corr rap_wb rap_wl rap_wii pap plap iap
alpha rap_wb rap_wl rap_wii, item
alpha pap plap iap, item
alpha rap_wb rap_wl rap_wii pap plap iap, item
factor rap_wb rap_wl rap_wii pap plap iap

save "2016 2020 ANES Combined.dta", replace

use "2016 2020 ANES Combined.dta", clear
drop if white_non != 1
drop if vote_conf_change == .

********************************************************************************
********************************************************************************
********************************************************************************
**#Manuscript Tables and Figures
********************************************************************************
********************************************************************************
********************************************************************************

********************************************************************************
**#Summary Stats
********************************************************************************

ologit vote_conf_change3 c.rap_wb ///
age educ income_mean married ///
voted conservativism rep_w_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
[pw=panel_weight], robust cluster(V160001_orig)

sum vote_conf_change5 rap_wb rap_wl rap_wii pap plap iap age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
if e(sample)==1

********************************************************************************
**#Histogram
********************************************************************************

hist vote_conf_change, ///
d ///
percent addlabels addlabopts(mlabformat(%4.2f)) ///
fcolor(gs7%50) ///
lcolor(gs7%50) ///
xlabel(-4(1)4) ///
name(hist_vote_conf_change, replace)
graph export hist_vote_conf_change.png, replace


********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x' ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'
margins,  ///
dydx(`x') at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4 rep_w_lean=0 ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_me
marginsplot, ///
 ytitle("Prob. Change in Confidence") ///
plot1opts(color(maroon%30) lpattern(dash)) ///
ci1opts(color(maroon%30)) ///
xscale(r(-.25 2.25)) ///
scheme(plotplain) ///
title("") ///
 name(`x', replace)
}

	*Marginal effects coefficient plot
	coefplot rap_wb_me rap_wl_me rap_wii_me pap_me plap_me iap_me, ///
	vertical ///
	xlabel(1 "+Decrease" 2 "Decrease" 3 "No Change" 4 "Increase" 5 "+ Increase") ///
	xline(1.5 2.5 3.5 4.5, lpattern(dash) lcolor(gs12%30)) ///
	xscale(r(.25 5.75) lcolor()) ///
	xtitle("Change in Voter Confidence") ///
	yline(0, lcolor(gs4) lpattern(dash)) ///
	yscale(r(-.35 .35)) ///
	ylabel(-0.3(.15).3) ///
	ytitle("Marginal Effect of Affective Polarization") ///
	scheme(plotplain) ///
	legend(order(2 "White-Black" 4 "White-Latino" 6 "White-Illeg. Im." 8 "Partisan" 10 "Party Leader" 12 "Ideological") row(2) pos(6) title("Affective Polarization") region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
	name(me_coef, replace)
	graph export me_coef.png, replace

	*Marginal effects table
	esttab rap_wb_me rap_wl_me rap_wii_me pap_me plap_me iap_me ///
	using me_ologit.rtf, replace ///
	cells(b(nostar fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	title("Table XX: Marginal Effect of Affective Polarization on Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label   

	esttab rap_wb_me rap_wl_me rap_wii_me pap_me plap_me iap_me ///
	using me_ologit.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Full table
	esttab rap_wb rap_wl rap_wii pap plap iap ///
	using confidence_ologit.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb rap_wl rap_wii pap plap iap ///
	using confidence_ologit.tex, replace ///
	 ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	 ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 


********************************************************************************
**# Republican Interaction
********************************************************************************

local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x'##i.rep_w_lean ///
age educ income_mean married ///
voted conservativism ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_rep_w_lean
margins rep_w_lean, dydx(`x') ///
at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4  ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_rep_w_lean_me
mplotoffset, ///
 ytitle("Marginal Effect of Affective Polarization") ///
plotopts(lcolor(white%0) lpattern(dash)) ///
ciopts() ///
scheme(plotplain) ///
xscale(r(-.5 1.5)) ///
yline(0, lcolor(gs4) lpattern(dash)) ///
title("") ///
legend(title("Change in Confidence") order(6 "+Decrease"  8 "No Change" 9 "Increase" 7 "Decrease" 20 "" 10 "+Increase") pos(6) col(3) region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
 name(`x'_rep_w_lean, replace)
 graph export `x'_rep_w_lean.png, replace
}


	esttab rap_wb_rep_w_lean_me rap_wl_rep_w_lean_me rap_wii_rep_w_lean_me pap_rep_w_lean_me plap_rep_w_lean_me iap_rep_w_lean_me ///
	using me_rep_ologit.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	
	*Table
	esttab rap_wb_rep_w_lean rap_wl_rep_w_lean rap_wii_rep_w_lean pap_rep_w_lean plap_rep_w_lean iap_rep_w_lean ///
	using confidence_ologit_rep_w_lean.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization, Partisanship, and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_rep_w_lean rap_wl_rep_w_lean rap_wii_rep_w_lean pap_rep_w_lean plap_rep_w_lean iap_rep_w_lean ///
	using confidence_ologit_rep_w_lean.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	
********************************************************************************
********************************************************************************
********************************************************************************
**#9-Point RC
********************************************************************************
********************************************************************************
********************************************************************************

********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change c.`x' ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'9
margins,  ///
dydx(`x') at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4 rep_w_lean=0 ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_me9
marginsplot, ///
 ytitle("Prob. Change in Confidence") ///
plot1opts(color(maroon%30) lpattern(dash)) ///
ci1opts(color(maroon%30)) ///
xscale(r(-.25 2.25)) ///
scheme(plotplain) ///
title("") ///
 name(`x'9, replace)
}

	*Marginal effects coefficient plot
	coefplot rap_wb_me9 rap_wl_me9 rap_wii_me9 pap_me9 plap_me9 iap_me9, ///
	vertical ///
	xlabel(1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "No Change" 6 "+1" 7 "+2" 8 "+3" 9 "+4") ///
	xline(1.5 2.5 3.5 4.5, lpattern(dash) lcolor(gs12%30)) ///
	xscale(r(.25 5.75) lcolor()) ///
	xtitle("Change in Voter Confidence") ///
	yline(0, lcolor(gs4) lpattern(dash)) ///
	yscale(r(-.35 .35)) ///
	ylabel(-0.3(.15).3) ///
	ytitle("Marginal Effect of Affective Polarization") ///
	scheme(plotplain) ///
	legend(order(2 "White-Black" 4 "White-Latino" 6 "White-Illeg. Im." 8 "Partisan" 10 "Party Leader" 12 "Ideological") row(2) pos(6) title("Affective Polarization") region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
	name(me_coef, replace)
	graph export me_coef9.png, replace

	*Marginal effects table
	esttab rap_wb_me9 rap_wl_me9 rap_wii_me9 pap_me9 plap_me9 iap_me9 ///
	using me_ologit9.rtf, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels( ///
	1._predict "-4" ///
	2._predict "-3" ///
	3._predict "-2" ///
	4._predict "-1" ///
	5._predict "No Change" ///
	6._predict "+1" ///
	7._predict "+2" ///
	8._predict "+3" ///
	9._predict "+4" ) ///
	title("Table XX: Marginal Effect of Affective Polarization on Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label   

	esttab rap_wb_me9 rap_wl_me9 rap_wii_me9 pap_me9 plap_me9 iap_me9 ///
	using me_ologit9.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Full table
	esttab rap_wb9 rap_wl9 rap_wii9 pap9 plap9 iap9 ///
	using confidence_ologit9.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb9 rap_wl9 rap_wii9 pap9 plap9 iap9 ///
	using confidence_ologit9.tex, replace ///
	 ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	 ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 


********************************************************************************
**# Republican Interaction
********************************************************************************

local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change c.`x'##i.rep_w_lean ///
age educ income_mean married ///
voted conservativism ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_rep_w_lean9
margins rep_w_lean, dydx(`x') ///
at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4  ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_rep_w_lean_me9
mplotoffset, ///
 ytitle("Marginal Effect of Affective Polarization") ///
plotopts(lcolor(white%0) lpattern(dash)) ///
ciopts() ///
scheme(plotplain) ///
xscale(r(-.5 1.5)) ///
yline(0, lcolor(gs4) lpattern(dash)) ///
title("") ///
legend(title("Change in Confidence") order(6 "+Decrease"  8 "No Change" 9 "Increase" 7 "Decrease" 20 "" 10 "+Increase") pos(6) col(3) region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
 name(`x'_rep_w_lean, replace)
 graph export `x'_rep_w_lean9.png, replace
}

	esttab rap_wb_rep_w_lean_me9 rap_wl_rep_w_lean_me9 rap_wii_rep_w_lean_me9 pap_rep_w_lean_me9 plap_rep_w_lean_me9 iap_rep_w_lean_me9 ///
	using me_rep_ologit9.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 
	
	*Table
	esttab rap_wb_rep_w_lean rap_wl_rep_w_lean rap_wii_rep_w_lean pap_rep_w_lean plap_rep_w_lean iap_rep_w_lean ///
	using confidence_ologit_rep_w_lean9.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization, Partisanship, and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_rep_w_lean rap_wl_rep_w_lean rap_wii_rep_w_lean pap_rep_w_lean plap_rep_w_lean iap_rep_w_lean ///
	using confidence_ologit_rep_w_lean9.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

********************************************************************************
********************************************************************************
********************************************************************************
**# OLS RC
********************************************************************************
********************************************************************************
********************************************************************************

********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
reg vote_conf_change01 c.`x' ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_ols
margins, ///
at(`x'=(-1(2)1) age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4 rep_w_lean=0 ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_pp_ols
marginsplot, ///
 ytitle("Prob. Change in Confidence") ///
plot1opts(color(maroon%30) lpattern(dash)) ///
ci1opts(color(maroon%30)) ///
xscale(r(-.25 2.25)) ///
scheme(plotplain) ///
title("") ///
legend(title("Change in Confidence") order(4 "Decrease" 5 "No Change" 6 "Increase") pos(6) row(1)) ///
name(`x'_ols, replace)
}

	*Marginal effects coefficient plot
	coefplot rap_wb_pp_ols rap_wl_pp_ols rap_wii_pp_ols pap_pp_ols plap_pp_ols iap_pp_ols, ///
	vertical ///
	xlabel(1 "Low RAP" 2 "High RAP") ///
	scheme(plotplain) ///
	legend(order(2 "White-Black" 4 "White-Latino" 6 "White-Illeg. Im." 8 "Partisan" 10 "Party Leader" 12 "Ideological") row(2) pos(6) title("Affective Polarization") region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
	name(pp_coef, replace)
	graph export pp_coef_ols.png, replace

	/*
	*Marginal effects table
	coefplot rap_wb_me_ols rap_wl_me_ols rap_wii_me_ols pap_me_ols plap_me_ols iap_me_ols ///
	using me_ols.rtf replace ///
	cells(b(nostar fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	title("Table XX: Marginal Effect of Affective Polarization on Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label   

	coefplot rap_wb_me_ols rap_wl_me_ols rap_wii_me_ols pap_me_ols plap_me_ols iap_me_ols ///
	using me_ols.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 
*/
	*Full table
	esttab rap_wb_ols rap_wl_ols rap_wii_ols pap_ols plap_ols iap_ols ///
	using confidence_ols.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Linear regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). Dependent variable rescaled to range from 0-1 for ease of interpretation. *0.05 **0.01 ***0.001.") ///
	stats(r2 r2_a N, fmt(3 3 0) label("R2" "Adj. R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_ols rap_wl_ols rap_wii_ols pap_ols plap_ols iap_ols ///
	using confidence_ols.tex, replace ///
	 ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	 ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 


********************************************************************************
**# Republican Interaction
********************************************************************************

local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
reg vote_conf_change5 c.`x'##i.rep_w_lean ///
age educ income_mean married ///
voted conservativism ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
[pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_rep_w_lean_ols
margins rep_w_lean, dydx(`x') ///
at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4  ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_rep_w_lean_ols_me
mplotoffset, ///
 ytitle("Marginal Effect of Affective Polarization") ///
plotopts(lcolor(white%0) lpattern(dash)) ///
ciopts() ///
scheme(plotplain) ///
xscale(r(-.5 1.5)) ///
yline(0, lcolor(gs4) lpattern(dash)) ///
title("") ///
legend(title("Change in Confidence") order(6 "+Decrease"  8 "No Change" 9 "Increase" 7 "Decrease" 20 "" 10 "+Increase") pos(6) col(3) region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
 name(`x'_trump_voter, replace)
 graph export `x'_rep_w_lean_ols.png, replace
}

	*Table
	esttab rap_wb_rep_w_lean_ols rap_wl_rep_w_lean_ols rap_wii_rep_w_lean_ols pap_rep_w_lean_ols plap_rep_w_lean_ols iap_rep_w_lean_ols ///
	using confidence_ologit_rep_w_lean_ols.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Linear regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). Dependent variable rescaled to range from 0-1 for ease of interpretation. *0.05 **0.01 ***0.001.") ///
	stats(r2 r2_a N, fmt(3 3 0) label("R2" "Adj. R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop() ///
	compress ///
 	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization, Partisanship, and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_rep_w_lean_ols rap_wl_rep_w_lean_ols rap_wii_rep_w_lean_ols pap_rep_w_lean_ols plap_rep_w_lean_ols iap_rep_w_lean_ols ///
	using confidence_ologit_rep_w_lean.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop() ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	
********************************************************************************
********************************************************************************
********************************************************************************
**# Full Sample RC
********************************************************************************
********************************************************************************
********************************************************************************

use "2016 2020 ANES Combined.dta", clear
drop if vote_conf_change == .

********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x' ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_fs
margins,  ///
dydx(`x') at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4 rep_w_lean=0 ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_me_fs
marginsplot, ///
 ytitle("Prob. Change in Confidence") ///
plot1opts(color(maroon%30) lpattern(dash)) ///
ci1opts(color(maroon%30)) ///
xscale(r(-.25 2.25)) ///
scheme(plotplain) ///
title("") ///
 name(`x'_fs, replace)
}

	*Marginal effects coefficient plot
	coefplot rap_wb_me_fs rap_wl_me_fs rap_wii_me_fs pap_me_fs plap_me_fs iap_me_fs, ///
	vertical ///
	xlabel(1 "+Decrease" 2 "Decrease" 3 "No Change" 4 "Increase" 5 "+ Increase") ///
	xline(1.5 2.5 3.5 4.5, lpattern(dash) lcolor(gs12%30)) ///
	xscale(r(.25 5.75) lcolor()) ///
	xtitle("Change in Voter Confidence") ///
	yline(0, lcolor(gs4) lpattern(dash)) ///
	yscale(r(-.35 .35)) ///
	ylabel(-0.3(.15).3) ///
	ytitle("Marginal Effect of Affective Polarization") ///
	scheme(plotplain) ///
	legend(order(2 "White-Black" 4 "White-Latino" 6 "White-Illeg. Im." 8 "Partisan" 10 "Party Leader" 12 "Ideological") row(2) pos(6) title("Affective Polarization") region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
	name(me_coef_fs, replace)
	graph export me_coef_fs.png, replace

	*Marginal effects table
	esttab rap_wb_me_fs rap_wl_me_fs rap_wii_me_fs pap_me_fs plap_me_fs iap_me_fs ///
	using me_ologit_fs.rtf, replace ///
	cells(b(nostar fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	title("Table XX: Marginal Effect of Affective Polarization on Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label   

	esttab rap_wb_me_fs rap_wl_me_fs rap_wii_me_fs pap_me_fs plap_me_fs iap_me_fs ///
	using me_ologit_fs.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Full table
	esttab rap_wb_fs rap_wl_fs rap_wii_fs pap_fs plap_fs iap_fs ///
	using confidence_ologit_fs.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_fs rap_wl_fs rap_wii_fs pap_fs plap_fs iap_fs ///
	using confidence_ologit_fs.tex, replace ///
	 ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	 ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 


********************************************************************************
**# Republican Interaction
********************************************************************************

local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x'##i.rep_w_lean ///
age educ income_mean married ///
voted conservativism ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_rep_w_lean_fs
margins rep_w_lean, dydx(`x') ///
at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4  ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_rep_w_lean_me_fs
mplotoffset, ///
 ytitle("Marginal Effect of Affective Polarization") ///
plotopts(lcolor(white%0) lpattern(dash)) ///
ciopts() ///
scheme(plotplain) ///
xscale(r(-.5 1.5)) ///
yline(0, lcolor(gs4) lpattern(dash)) ///
title("") ///
legend(title("Change in Confidence") order(6 "+Decrease"  8 "No Change" 9 "Increase" 7 "Decrease" 20 "" 10 "+Increase") pos(6) col(3) region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
 name(`x'_rep_w_lean, replace)
 graph export `x'_rep_w_lean_fs.png, replace
}

	esttab rap_wb_rep_w_lean_me_fs rap_wl_rep_w_lean_me_fs rap_wii_rep_w_lean_me_fs pap_rep_w_lean_me_fs plap_rep_w_lean_me_fs iap_rep_w_lean_me_fs ///
	using me_rep_ologit_fs.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Table
	esttab rap_wb_rep_w_lean_fs rap_wl_rep_w_lean_fs rap_wii_rep_w_lean_fs pap_rep_w_lean_fs plap_rep_w_lean_fs iap_rep_w_lean_fs ///
	using confidence_ologit_rep_w_lean_fs.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization, Partisanship, and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_rep_w_lean_fs rap_wl_rep_w_lean_fs rap_wii_rep_w_lean_fs pap_rep_w_lean_fs plap_rep_w_lean_fs iap_rep_w_lean_fs ///
	using confidence_ologit_rep_w_lean_fs.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

********************************************************************************
********************************************************************************
********************************************************************************
**# Non White Sample RC
********************************************************************************
********************************************************************************
********************************************************************************

use "2016 2020 ANES Combined.dta", clear
drop if white_non == 1
drop if vote_conf_change == .

********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x' ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_nws
margins,  ///
dydx(`x') at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4 rep_w_lean=0 ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_me_nws
marginsplot, ///
 ytitle("Prob. Change in Confidence") ///
plot1opts(color(maroon%30) lpattern(dash)) ///
ci1opts(color(maroon%30)) ///
xscale(r(-.25 2.25)) ///
scheme(plotplain) ///
title("") ///
 name(`x'_nws, replace)
}

	*Marginal effects coefficient plot
	coefplot rap_wb_me_nws rap_wl_me_nws rap_wii_me_nws pap_me_nws plap_me_nws iap_me_nws, ///
	vertical ///
	xlabel(1 "+Decrease" 2 "Decrease" 3 "No Change" 4 "Increase" 5 "+ Increase") ///
	xline(1.5 2.5 3.5 4.5, lpattern(dash) lcolor(gs12%30)) ///
	xscale(r(.25 5.75) lcolor()) ///
	xtitle("Change in Voter Confidence") ///
	yline(0, lcolor(gs4) lpattern(dash)) ///
	yscale(r(-.35 .35)) ///
	ylabel(-0.3(.15).3) ///
	ytitle("Marginal Effect of Affective Polarization") ///
	scheme(plotplain) ///
	legend(order(2 "White-Black" 4 "White-Latino" 6 "White-Illeg. Im." 8 "Partisan" 10 "Party Leader" 12 "Ideological") row(2) pos(6) title("Affective Polarization") region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
	name(me_coef_nws, replace)
	graph export me_coef_nws.png, replace

	*Marginal effects table
	esttab rap_wb_me_nws rap_wl_me_nws rap_wii_me_nws pap_me_nws plap_me_nws iap_me_nws ///
	using me_ologit_nws.rtf, replace ///
	cells(b(nostar fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	title("Table XX: Marginal Effect of Affective Polarization on Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label   

	esttab rap_wb_me_nws rap_wl_me_nws rap_wii_me_nws pap_me_nws plap_me_nws iap_me_nws ///
	using me_ologit_nws.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Full table
	esttab rap_wb_nws rap_wl_nws rap_wii_nws pap_nws plap_nws iap_nws ///
	using confidence_ologit_nws.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_nws rap_wl_nws rap_wii_nws pap_nws plap_nws iap_nws ///
	using confidence_ologit_nws.tex, replace ///
	 ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	 ///
	order(rap_wb rap_wl rap_wii pap plap iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 


********************************************************************************
**# Republican Interaction
********************************************************************************

local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x'##i.rep_w_lean ///
age educ income_mean married ///
voted conservativism ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_rep_w_lean_nws
margins rep_w_lean, dydx(`x') ///
at(age=55 educ=4 income_mean=12 married=1 ///
voted=1 conservativism=4  ind_no_lean=0 know_party_ingov_index=1 poli_int_politics=3 ///
racial_importance=2 rr_scale=.5 thinks_has_id=0 consp_scale=.46 ///
) atmeans post
estimates store `x'_rep_w_lean_me_nws
mplotoffset, ///
 ytitle("Marginal Effect of Affective Polarization") ///
plotopts(lcolor(white%0) lpattern(dash)) ///
ciopts() ///
scheme(plotplain) ///
xscale(r(-.5 1.5)) ///
yline(0, lcolor(gs4) lpattern(dash)) ///
title("") ///
legend(title("Change in Confidence") order(6 "+Decrease"  8 "No Change" 9 "Increase" 7 "Decrease" 20 "" 10 "+Increase") pos(6) col(3) region(lstyle(solid) lcolor(black) lwidth(vthin))) ///
 name(`x'_rep_w_lean, replace)
 graph export `x'_rep_w_lean_nws.png, replace
}

	esttab rap_wb_rep_w_lean_me_nws rap_wl_rep_w_lean_me_nws rap_wii_rep_w_lean_me_nws pap_rep_w_lean_me_nws plap_rep_w_lean_me_nws iap_rep_w_lean_me_nws ///
	using me_rep_ologit_nws.tex, replace ///
	cells(b(star fmt(3)) p(fmt(3) par)) /// 
	eqlabel("Change in Confidence") ///
	varlabels(1._predict "+Decrease" 2._predict "Decrease" ///
	3._predict "No Change" ///
	4._predict "Increase" 5._predict "+Increase") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") ///
	label 

	*Table
	esttab rap_wb_rep_w_lean_nws rap_wl_rep_w_lean_nws rap_wii_rep_w_lean_nws pap_rep_w_lean_nws plap_rep_w_lean_nws iap_rep_w_lean_nws ///
	using confidence_ologit_rep_w_lean_nws.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization, Partisanship, and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

	esttab rap_wb_rep_w_lean_nws rap_wl_rep_w_lean_nws rap_wii_rep_w_lean_nws pap_rep_w_lean_nws plap_rep_w_lean_nws iap_rep_w_lean_nws ///
	using confidence_ologit_rep_w_lean_nws.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.rep_w_lean rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 

********************************************************************************
********************************************************************************
********************************************************************************
**# 2016 Confidence Hetero test
********************************************************************************
********************************************************************************
********************************************************************************

use "2016 2020 ANES Combined.dta", clear
drop if white_non != 1
drop if vote_conf_change == .

********************************************************************************
**# Change in confidence
********************************************************************************
local vars rap_wa rap_wb rap_wl rap_wii pap plap iap
foreach x of local vars {
ologit vote_conf_change5 c.`x'##i.vote_conf_2016 ///
age educ income_mean married ///
voted conservativism rep_w_lean ind_no_lean know_party_ingov_index poli_int_politics ///
racial_importance rr_scale thinks_has_id consp_scale ///
i.state_fips [pw=panel_weight], robust cluster(V160001_orig)
estimates store `x'_16c
}

	*Full table
	esttab rap_wb_16c rap_wl_16c rap_wii_16c pap_16c plap_16c iap_16c ///
	using confidence_ologit_16c.rtf, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.01) ///
	label note("Ordered logistic regression with robust standard errors clustered by respondent and include state fixed effects (omitted for space). *0.05 **0.01 ***0.001.") ///
	stats(ll r2_p N, fmt(3 3 0) label("Log Like." "Pseudo R2" "N") ) ///
	nodepvars nobase noomitted eqlabel("" "Cuts") interaction(" x ") ///
	drop(*.state_fips) ///
	compress ///
	order(*.vote_conf_2016 rap_wb *.rap_wb rap_wl *.rap_wl rap_wii *.rap_wii pap *.pap plap *.plap iap *.iap) ///
	title("Table XX: Affective Polarization and Change in Voter Confidence (2016 to 2020)") ///
	mlabel("White-Black" "White-Latino" "White-Illegal Immig." "Partisan" "Party Leader" "Ideological") 
